/*     */ package com.zimbra.cs.mailclient.imap;
/*     */ 
/*     */ import java.io.IOException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Envelope
/*     */ {
/*     */   private String date;
/*     */   private String subject;
/*     */   private Address[] from;
/*     */   private Address[] sender;
/*     */   private Address[] replyTo;
/*     */   private Address[] to;
/*     */   private Address[] cc;
/*     */   private Address[] bcc;
/*     */   private String inReplyTo;
/*     */   private String messageId;
/*     */   
/*     */   public static Envelope read(ImapInputStream is)
/*     */     throws IOException
/*     */   {
/*  60 */     Envelope env = new Envelope();
/*  61 */     env.readEnvelope(is);
/*  62 */     return env;
/*     */   }
/*     */   
/*     */   private void readEnvelope(ImapInputStream is) throws IOException {
/*  66 */     is.skipSpaces();
/*  67 */     is.skipChar('(');
/*  68 */     this.date = is.readNString();
/*  69 */     is.skipChar(' ');
/*  70 */     this.subject = is.readNString();
/*  71 */     is.skipChar(' ');
/*  72 */     this.from = readAList(is);
/*  73 */     is.skipChar(' ');
/*  74 */     this.sender = readAList(is);
/*  75 */     is.skipChar(' ');
/*  76 */     this.replyTo = readAList(is);
/*  77 */     is.skipChar(' ');
/*  78 */     this.to = readAList(is);
/*  79 */     is.skipChar(' ');
/*  80 */     this.cc = readAList(is);
/*  81 */     is.skipChar(' ');
/*  82 */     this.bcc = readAList(is);
/*  83 */     is.skipChar(' ');
/*  84 */     this.inReplyTo = is.readNString();
/*  85 */     is.skipChar(' ');
/*  86 */     this.messageId = is.readNString();
/*  87 */     is.skipSpaces();
/*  88 */     is.skipChar(')');
/*     */   }
/*     */   
/*     */   private static Address[] readAList(ImapInputStream is) throws IOException {
/*  92 */     is.skipSpaces();
/*  93 */     if (is.match('(')) {
/*  94 */       List<Address> addrs = new ArrayList();
/*  95 */       is.skipSpaces();
/*  96 */       while (!is.match(')')) {
/*  97 */         addrs.add(readAddress(is));
/*  98 */         is.skipSpaces();
/*     */       }
/* 100 */       return (Address[])addrs.toArray(new Address[addrs.size()]);
/*     */     }
/* 102 */     is.skipNil();
/* 103 */     return null;
/*     */   }
/*     */   
/*     */   private static Address readAddress(ImapInputStream is) throws IOException
/*     */   {
/* 108 */     is.skipChar('(');
/* 109 */     Address addr = new Address();
/* 110 */     addr.name = is.readNString();
/* 111 */     is.skipChar(' ');
/* 112 */     addr.adl = is.readNString();
/* 113 */     is.skipChar(' ');
/* 114 */     addr.host = is.readNString();
/* 115 */     is.skipChar(' ');
/* 116 */     addr.mailbox = is.readNString();
/* 117 */     is.skipSpaces();
/* 118 */     is.skipChar(')');
/* 119 */     return addr;
/*     */   }
/*     */   
/* 122 */   public String getDate() { return this.date; }
/* 123 */   public String getSubject() { return this.subject; }
/* 124 */   public String getMessageId() { return this.messageId; }
/* 125 */   public Address[] getFrom() { return this.from; }
/* 126 */   public Address[] getSender() { return this.sender; }
/* 127 */   public Address[] getReplyTo() { return this.replyTo; }
/* 128 */   public Address[] getTo() { return this.to; }
/* 129 */   public Address[] getCc() { return this.cc; }
/* 130 */   public Address[] getBcc() { return this.bcc; }
/* 131 */   public String getInReplyTo() { return this.inReplyTo; }
/*     */   
/*     */   public static class Address {
/*     */     private String name;
/*     */     private String adl;
/*     */     private String host;
/*     */     private String mailbox;
/*     */     
/* 139 */     public String getName() { return this.name; }
/* 140 */     public String getAdl() { return this.adl; }
/* 141 */     public String getHost() { return this.host; }
/* 142 */     public String getMailbox() { return this.mailbox; }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailclient/imap/Envelope.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */